#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 3001;
int n;
int q[N];
int f[N], g[N];
void firstnum()
{

    int res = 0;
    for (int i = 0; i < n; i++) {
        f[i] = 1;
        for (int j = 0; j < i; j++)
            if (q[j] >= q[i])
                f[i] = max(f[i], f[j] + 1);
        res = max(res, f[i]);
    }
    cout << res << endl;
}
void secnum()
{
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int k = 0;
        while (k < cnt && g[k] < q[i])   k++;
        g[k] = q[i];
        if (k >= cnt) cnt++;
    }

    cout << cnt << endl;

   
}
int main() {
    while (cin >> q[n]) n++;
    firstnum();

    secnum();
    return 0;
}